package com.storeroompda.utils;

import android.graphics.Canvas;
import android.graphics.Rect;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

/**
 * Created by dell on 2017/12/7.
 * 设置RecycleViewItem间距
 */

public class SpacesItemDecoration extends RecyclerView.ItemDecoration {

    private int left;
    private int top;
    private int right;
    private int bottom;
    public SpacesItemDecoration(int left, int top,int right,int bottom) {
        this.left = left;
        this.top = top;
        this.right = right;
        this.bottom = bottom;
    }

    @Override
    public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
        super.onDraw(c, parent, state);
    }

    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
        LinearLayoutManager layoutManager = (LinearLayoutManager) parent.getLayoutManager();
//        if (parent.getChildAdapterPosition(view) == layoutManager.getItemCount() - 1) {
//            outRect.right = leftRight;
//        }
        outRect.top = top;
        outRect.left = left;
        outRect.right = right;
        outRect.bottom = bottom;

    }


}
